<%--
  Created by IntelliJ IDEA.
  User: dhf
  Date: 2019/12/3
  Time: 16:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>机构详情</title>
    <meta name="renderer" content="webkit" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta
            name="viewport"
            content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"
    />
    <link rel="stylesheet" href="../../static/lib/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="../../static/css/admin.css" media="all" />
</head>
<body>
<div id="TMM_app">
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-body" style="padding: 15px;">
                <form
                        class="layui-form"
                        id="tmm-form-org-show" action="${paht}/merchant/saveExpressInfo"
                        lay-filter="component-form-group"
                >
                    <div class="form-title">基本信息</div>
                    <div class="layui-row">
                        <div class="layui-col-md9 layui-col-lg6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">店家名称</label>
                                <div class="layui-input-block">
                                    <div class="layui-form-mid">${merchant.name}</div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">地址</label>
                                <div class="layui-input-block">
                                    <div class="layui-form-mid">${merchant.address}</div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">联系电话</label>
                                <div class="layui-input-block">
                                    <div class="layui-form-mid">${merchant.tel}</div>
                                </div>
                            </div>
                            <div class="form-title">商户信息</div>
                            <div id="divShow">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">收货人</label>
                                    <div class="layui-input-block">
                                        <div class="layui-form-mid">${merchant.merchantExpressInfo.name}</div>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">收货电话</label>
                                    <div class="layui-input-block">
                                        <div class="layui-form-mid">${merchant.merchantExpressInfo.phone}</div>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">收货地址</label>
                                    <div class="layui-input-block">
                                        <div class="layui-form-mid">${merchant.merchantExpressInfo.address}</div>
                                    </div>
                                </div>
                            </div>

                            <div id="divEdit" style="display: none">
                                <div class="layui-form-item">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">收货人</label>
                                        <div class="layui-input-block">
                                            <input
                                                    type="text"
                                                    name="name"
                                                    value="${merchant.merchantExpressInfo.name}"
                                                    lay-verify="title"
                                                    autocomplete="off"
                                                    placeholder="请输入收货人"
                                                    class="layui-input"
                                            />
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">收货电话</label>
                                        <div class="layui-input-block">
                                            <input
                                                    type="text"
                                                    name="phone"
                                                    value="${merchant.merchantExpressInfo.phone}"
                                                    lay-verify="title"
                                                    autocomplete="off"
                                                    placeholder="请输入收货电话"
                                                    class="layui-input"
                                            />
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">收货地址</label>
                                        <div class="layui-input-block">
                                            <input
                                                    type="text"
                                                    name="address"
                                                    value="${merchant.merchantExpressInfo.address}"
                                                    lay-verify="title"
                                                    autocomplete="off"
                                                    placeholder="请输入收货地址"
                                                    class="layui-input"
                                            />
                                        </div>
                                    </div>
                                </div>
                            </div>
<%--                            <div class="layui-form-item">--%>
<%--                                <label class="layui-form-label">手术室数量</label>--%>
<%--                                <div class="layui-input-block">--%>
<%--                                    <div class="layui-form-mid">${merchant.room2}</div>--%>
<%--                                </div>--%>
<%--                            </div>--%>
<%--                            <div class="layui-form-item layui-form-text">--%>
<%--                                <label class="layui-form-label">医院简介</label>--%>
<%--                                <div class="layui-input-block">--%>
<%--                                    <div class="layui-form-mid">--%>
<%--                                        ${merchant.desc}--%>
<%--                                    </div>--%>
<%--                                </div>--%>
<%--                            </div>--%>
<%--                            <div class="layui-form-item">--%>
<%--                                <label class="layui-form-label">医院地址</label>--%>
<%--                                <div class="layui-input-block">--%>
<%--                                    <div class="layui-form-mid">--%>
<%--                                        ${merchant.address}--%>
<%--                                    </div>--%>
<%--                                </div>--%>
<%--                            </div>--%>
                        </div>
                        <div
                                class="layui-col-md3 layui-col-lg2 text-center tmm-right-logo"
                        >
                            <img class="org_logo" src="${merchant.logo}" />
                            <div>机构LOGO</div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <div class="layui-footer">
                                <div id="editButton">
                                    <button class="layui-btn tmm-btn-primary" type="button" id="edit_button" style="width: 150px">
                                        编辑
                                    </button>
                                </div>
                                <div id="saveButton" style="display: none">
                                    <button class="layui-btn tmm-btn-primary" type="button" id="save_button" style="width: 150px">
                                        保存
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<script src="../../static/lib/layui/layui.js"></script>
<script>
    layui
        .config({
            base: "../../static/js/"
        })
        .extend({
            index: "index"
        })
        .use(["index", "form", "laydate", "upload"], function() {
            var $ = layui.$,
                admin = layui.admin,
                element = layui.element,
                layer = layui.layer,
                laydate = layui.laydate,
                upload = layui.upload,
                form = layui.form;

            $("#edit_button").click(function() {
                $("#divShow").hide();
                $("#divEdit").show();

                $("#editButton").hide();
                $("#saveButton").show();

                // $("#tmm-form-org-edit").show();
                // $("#tmm-form-org-show").hide();
                return false;
            });

            $("#save_button").click(function () {
                var load = layer.load(2);
                $.ajax({
                    type: "post",
                    url: "${path}/merchant/saveExpressInfo",
                    dataType: "json",
                    data:$("#tmm-form-org-show").serialize(),
                    success: function (data) {
                        layer.close(load);
                        if(data.code!=200){
                            layer.msg(data.msg, {
                                offset: '200px'
                                ,icon: 2
                                ,time: 1000
                                ,anim:4
                            }, function(){});
                            return false;
                        }else{
                            layer.msg(data.msg, {
                                offset: '200px'
                                ,icon: 1
                                ,time: 1000
                                ,anim:4
                            }, function(){
                                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                parent.location.reload();//刷新父页面，注意一定要在关闭当前iframe层之前执行刷新
                                parent.layer.close(index); //再执行关闭
                            });
                            return;
                        }
                        return false;
                    },
                    error:function () {
                        layer.close(load);
                    }
                });
            })
        });

</script>
</body>
</html>

